import { Entity, PrimaryGeneratedColumn, Column, ManyToOne, CreateDateColumn } from 'typeorm';
import { User } from '../../users/entities/user.entity';
import { OperationType } from '../../operation-types/entities/operation-type.entity';

@Entity('timer_records')
export class TimerRecord {
  @PrimaryGeneratedColumn()
  id: number;

  @ManyToOne(() => User, user => user.id)
  user: User;

  @Column()
  operator: string;

  @Column({ type: 'int', nullable: true })
  duration: number; // 用时(秒)

  @Column({ type: 'datetime' })
  startTime: Date;

  @Column({ type: 'datetime', nullable: true })
  endTime: Date;

  @ManyToOne(() => OperationType, operationType => operationType.id)
  operationType: OperationType;

  @Column({ default: 'completed' })
  status: string; // 'running' or 'completed'

  @CreateDateColumn()
  createdAt: Date;
}